<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <link rel="stylesheet" href="css/login.css">
    <link rel="stylesheet" href="css/style.css">

    <style>
        body {
            background: url(../images/timg6.jpg) no-repeat fixed;
            background-size: cover;
            width: 100%;
        }
    </style>
</head>

<body>
    <div id="" class="container p-3 mb-5 rounded shadow" style="font-family: cursive;">
        <!-- 登录标题框 -->
        <div id="title" style="margin-bottom: 2rem;">
            <h1 style="text-align: center; padding-top: 0.5rem;">登 陆</h1>
        </div>

        <form id="loginForm" action="/loginDone" method="POST">
            <!-- 文本框 -->
            <div id="body_middle">
                <!-- 账号框 -->
                <div class="row">
                    <img src="images/用户名.png" alt=""
                        style="width: 25px; height: 25px; position: absolute; left: 6rem; top: 7rem;">
                    <div class="col">
                        <center>
                            <input type="text" class="form-control" id="username" name="username"
                                placeholder="用户名/手机号/邮箱" style="width: 50%; text-align: center;">
                            <i class="fa fa-unlock-alt" aria-hidden="true"></i>
                        </center>
                    </div>
                </div>
                <!-- 密码框 -->
                <div class="row">
                    <img src="images/锁头.png" alt=""
                        style="width: 25px; height: 25px; position: absolute; left: 6rem; top: 10.5rem;">
                    <div class="col">
                        <center>
                            <input type="password" class="form-control" id="password" name="password"
                                placeholder="请输入密码" style="width: 50%; text-align: center">
                            <i class="fa fa-unlock-alt" aria-hidden="true"></i>
                            <!-- 功能小眼睛 -->
                            <img src="image/eye-slash.svg" alt="" id="eyes"
                                style="margin-right: 6.6rem; margin-top: 0px; ">
                        </center>
                    </div>
                </div>
            </div>

            <!-- 辅助板块 -->
            <div>
                <div class="row">
                    <div class="col">

                    </div>
                </div>
                <!-- 按钮组件 -->
                <div style="text-align: center;">
                    <div class="form-group-3 form-check">
                        <input type="checkbox" class="form-check-input" id="exampleCheck1">
                        <label class="form-check-label" for="exampleCheck1">
                            <h6>Remember Me</h6>
                        </label>
                    </div>
                    <button type="button" class="btn btn-outline-success" style="width: 14.5rem;"
                        onclick="jump()">登录</button>
                </div>
                <div class="form-group btn">
                    <a href="#" onclick="register()">
                        <h6>注册账号</h6>
                    </a>
                </div>
                <div class="form-group btn" style="margin-left: 12rem;">
                    <a href="#" onclick="">
                        <h6>忘记密码</h6>
                    </a>
                </div>
            </div>
        </form>

        <!-- 提示 -->
        <div class="col">
            <div class="alert alert-danger alert-dismissible fade show invisible" role="alert">
                <strong class="alert-dan">提示：</strong><label for="" id="msgId">敦煌</label>
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
        </div>
        
    </div>

    <!-- 壁纸切换 -->
    <div id="div_NetMonitor"> 
        <div id="div_netMon1" onclick="checkNet1()"><img src="../images/timg2.jpg"></div>
        <div id="div_netMon2" onclick="checkNet2()"><img src="../images/timg3.jpg"></div>
        <div id="div_netMon3" onclick="checkNet3()"><img src="../images/timg4.jpg"></div>
        <div id="div_netMon4" onclick="checkNet4()"><img src="../images/timg5.jpg"></div>

        <div id="div_netMon5">Wallpaper</div>

        <div id="div_netMon6" title="Wallpaper" onclick="checkWallpaper()">
            <svg t="1590074189701" class="icon-suspension" id="icon-sus1" viewBox="0 0 1000 1000" version="1.1"
                p-id="1773" width="200" height="200">
                <path
                    d="M500 0c-276.1563 0-500 223.8438-500 500s223.8438 500 500 500 500-223.8438 500-500-223.8438-500-500-500zM500 906.25c-224.375 0-406.25-181.875-406.25-406.25s181.875-406.25 406.25-406.25 406.25 181.875 406.25 406.25-181.875 406.25-406.25 406.25zM794.1875 455.8125l-250-250c-24.4063-24.4063-63.9688-24.4063-88.375 0s-24.4063 63.9688 0 88.375l143.3125 143.3125h-349.125c-34.5313 0-62.5 27.9688-62.5 62.5s27.9688 62.5 62.5 62.5h349.125l-143.3125 143.3125c-24.4063 24.4063-24.4063 63.9688 0 88.4063 12.2188 12.1875 28.1875 18.3125 44.1875 18.3125s32-6.0938 44.1875-18.3125l250-250c24.4063-24.4063 24.4063-63.9688 0-88.375z"
                    fill="#1571fa" p-id="1774"></path>
            </svg>
            <svg t="1590076234376" class="icon-suspension" id="icon-sus2" viewBox="0 0 1000 1000" version="1.1"
                p-id="5476" width="200" height="200">
                <path
                    d="M500 0c276.1563 0 500 223.8438 500 500s-223.8438 500-500 500-500-223.8438-500-500 223.8438-500 500-500zM500 906.25c224.375 0 406.25-181.875 406.25-406.25s-181.875-406.25-406.25-406.25-406.25 181.875-406.25 406.25 181.875 406.25 406.25 406.25zM205.8125 455.8125l250-250c24.4063-24.4063 63.9688-24.4063 88.375 0s24.4063 63.9688 0 88.375l-143.3125 143.3125h349.125c34.5313 0 62.5 27.9688 62.5 62.5s-27.9688 62.5-62.5 62.5h-349.125l143.3125 143.3125c24.4063 24.4063 24.4063 63.9688 0 88.4063-12.2188 12.1875-28.1875 18.3125-44.1875 18.3125s-32-6.0938-44.1875-18.3125l-250-250c-24.4063-24.4063-24.4063-63.9688 0-88.375z"
                    p-id="5477" fill="#1571fa"></path>
            </svg>
        </div>
    </div>

    <script src="js/jquery-3.5.1.min.js"></script>
    <script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <!-- 登录页输入框焦点逻辑 -->
    <script src="js/login_input_focus.js"></script>
    <!-- 小眼睛——显示隐藏密码实现逻辑 -->
    <script src="js/icon_click.js"></script>
    <!-- 壁纸 -->
    <script src="js/FormValidator.js"></script>

    <script>
        function register() {
            window.location.href = '/register';
        }
        function jump() {
            // 获取表单数据
            let uid = $('#username').val();
            let pwd = $('#password').val();

            // 判断用户名、密码是否为空，为空则提示；不为空则向服务器提交
            if (uid.length > 0 && pwd.length > 0) {
                axios({
                    method: 'post',
                    url: '/loginDone',
                    data: $('#loginForm').serialize(),
                }).then(function (res) {
                    // axios工具下，服务器真正返回的数据在返回对象的data中
                    res = res.data;
                    if (res.code === 200) {
                        window.location.href = '/';
                    } else {
                        alert_fn(res.msg);
                        console.log(res.msg);
                    }
                }).catch((err) => {
                    alert_fn(err);
                    console.log(err);
                });
            } else {
                alert_fn('用户名、密码不能为空');
            }
        }

        // 包装了显示（以及自动隐藏）消息警告的动作
        function alert_fn(msg) {
            $('#msgId').text(msg);
            $('.alert').removeClass('invisible');
            setTimeout(() => {
                $('.alert').addClass('invisible');
            }, 3000);
        }
    </script>
</body>

</html>